#define _CRT_SECURE_NO_WARNINGS  1
#pragma warning(disable:6031)

#include <stdio.h>
#include <string.h>

//字符串的逆序打印
int reverse_string(char* string)
{
	if (*string != '\0')
	{
		reverse_string(string + 1);
	}
	else
	{
		return 0;
	}
	printf("%c", *string);
}

//字符串的逆序排列
int reverse_string_p(char* string)
{
	int len = strlen(string);
	char tmp = *string;
	*string = *(string + len - 1);

	*(string + len - 1) = '\0';
	if (strlen(string + 1) >= 2)
    {
		reverse_string(string + 1);   
    }

	*(string + len - 1) = tmp;

}

//求第n个费波纳希数
int Fib(unsigned int n)
{
	if (n <= 2)
		return 1;
	else
		return Fib(n - 1) + Fib (n - 2);
}

//递归实现n的k次方
int power(unsigned int n, unsigned int k)
{
	if (n == 0)
	{
		return 0;
	}
	if (k != 0)
	{
		return n * power(n, k - 1);
	}
	else
	{
		return 1;
	}
}

//求一个数每位上的数字的和
int num_sum(num)
{
	if (num > 9)
	{
		return num % 10 + num_sum(num / 10);
	}
	else
		return num;
}

//求字符串的长度
int my_strlen(char* string)
{

	int count = 0;
	int i = 0;
	while (string[i] != '\0')
	{
		count++;
		i++;
	}
	return count;
}

//求n的阶乘
int n_power(unsigned int n)
{
	if (n > 1)
	{
		return n * n_power(n - 1);
	}
	else
		return 1;
}

//打印一个数的每一位
void num_print(int num)
{
	if (num > 9)
	{
		num_print(num / 10);
		printf("%d ", num % 10);
	}
	else
		printf("%d ", num);
}


int main()
{
////字符串的逆序打印
//	char string[10] = { '\0' };
//	scanf("%s", string);
//	reverse_string(string);

	char string[10] = { '\0' };
	scanf("%s", string);
	reverse_string_p(string);
	printf("%s\n", string);

//求第n个费波纳希数
	//递归法
	//unsigned int n = 0;
	//scanf("%u", &n);
	//int ret = Fib(n);
	//printf("%d\n", ret);


	////非递归法
	//unsigned int n = 0;
	//scanf("%u", &n);

	//int a = 1;
	//int b = 1;
	//int c = 1;
	//if (n > 2)
	//{
	//	for (int i = 2; i < n; i++)
	//	{
	//		c = a + b;
	//		a = b;
	//		b = c;
	//	}
	//}
	//printf("第n个斐波那契数是%d\n", c);



	//求n的k次方
	//unsigned int n = 0;
	//unsigned int k = 0;
	//scanf("%u%u", &n, &k);

	//int ret = power(n, k);
	//printf("%d\n", ret);



	////求一个数每位上的数字的和
	//unsigned int num = 0;
	//scanf("%u", &num);

	//int ret = num_sum(num);
	//printf("输入数字各位上的和是：%d\n", ret);



	//my_strlen的实现
	////非递归法
	//char string[100] = { 0 };
	//scanf("%s", string);

	//int count = 0;
	//int i = 0;
	//while (string[i] != '\0')
	//{
	//	count++;
	//	i++;
	//}
	//printf("字符串的长度为：%d", count);


	////递归法
	//char string[100] = { 0 };
	//scanf("%s", string);

	//int ret = my_strlen(string);
	//printf("字符串的长度是：%d\n", ret);



	////求阶乘（递归法）
	//unsigned int n = 0;
	//scanf("%u", &n);

	//int ret = n_power(n);
	//printf("%d", ret);


	////非递归
	//unsigned int n = 0;
	//scanf("%u", &n);

	//int i = 0;
	//int n_mul = 1;
	//for (i = 1; i <= n; i++)
	//{
	//	n_mul *= i;
	//}
	//printf("%d\n", n_mul);



	////打印一个数的每一位
	//unsigned int num = 0;
	//scanf("%u", &num);

	//num_print(num);
	return 0;
}